import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueLazyLoad from 'vue-lazyload'
import './plugins/element.js'
// import env from './env'
axios.defaults.baseURL = '/api'
axios.defaults.timeout = 8000
//根据环境变量获取不同的请求地址
// axios.defaults.baseURL='env.baseURL'
import VueCookie from 'vue-cookie'
Vue.use(VueCookie);
//接口错误连接
axios.interceptors.response.use(function (response) {
  let res = response.data
  let path = location.pathname
  if (res.status == 0) {
    return res.data
  } else if (res.status == 10) {
    if (path != '/index' && path != '/login') {
      window.location.href = '/login';
      return Promise.reject(res)
    }
    return Promise.reject(res);
  } else {
    this.$message.warning(res.msg);
    return Promise.reject(res.data.$message)
  }
}),(error)=>{
  let res =error.response;
  aleft(res)
  this.$message.error(res);
  return Promise.reject(error);
}
Vue.use(VueAxios, axios)
Vue.use(VueLazyLoad, {
  loading: '/imgs/loading-svg/loging-bars.svg'
})
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
